%Generate a number equal to numberOfLToBeDone of sdpvar() Matrix starting from matrix L.
%
%Generate a number equal to numberOfLToBeDone of Sdpvar Matrix starting
%from matrix L.
%
%Prototype: [sdpL] = generateSdpVarL(L, numberOfLToBeDone)
%
%Input:     L - Syms matrix of L
%           numberOfLToBeDone - Number of L to create depending of affine
%                               parameters.
%
%Output:    sdpL - Sdpvar version of L

function [ sdpL ] = generateSdpVarL( L, numberOfLToBeDone )

variables = strsplit(',',findsym(L));

for t = 1:numberOfLToBeDone
    sdpL{t} = '[';
    for i = 1:length(L)
        for j = 1:length(L)
            currentVariables =  strsplit(',',findsym(L(i,j)));
            currentRow = strrep(char(L(i,j)), ' ', '');
            if cellfun(@isempty,currentVariables)==false
                for k = 1:length(currentVariables)
                    counter = lookForVariableIndex(currentVariables(k),variables);
                    currentRow = strrep(currentRow,char(currentVariables(k)),strcat('alfa{',num2str(counter*t),'}'));
                end
            end
            sdpL{t} = [sdpL{t}, currentRow, ' '];
        end
        if i ~= length(L)
            sdpL{t} = strcat(sdpL{t},';');
        end
    end
    sdpL{t} = strcat(sdpL{t},']');
end

return;

end
